remotemanager.storage.trackedfile module

class remotemanager.storage.trackedfile.TrackedFile(local_path: str, remote_path: str, file: str, binary: bool = False)[source]
property binary: bool

Access to private _binary attribute.

property name: str

Returns the filename

property importstr: str

Returns the filename without extension

Suitable for python imports

property remote: str

Returns the full remote path

property local: str

Returns the full local path

property remote_dir: str

Returns the remote dir

property local_dir: str

Returns the full local dir

relative_remote_path(other: str) str[source]

Return a path relative to cwd

Parameters:

other – working dir to compare against

Returns:

relative path

property content: str | None

Attempts to read the file contents

Returns None if the file cannot be read

write(content: str | list, add_newline: bool = True) None[source]

Write content to the local copy of the file

Parameters:
  • content – content to write

  • add_newline – enforces a newline character at the end of the write if True (default True)

append(content: str | list, add_newline: bool = True) None[source]

Append content to the local copy of the file

Parameters:
  • content – content to append

  • add_newline – enforces a newline character at the end of the write if True (default True)

confirm_local(t: int | None = None) None[source]

Confirm sighting of the file locally

Parameters:

t – Optionally set the time to t instead of time.time()

confirm_remote(t: int | None = None) None[source]

Confirm sighting of the file on the remote

Parameters:

t – Optionally set the time to t instead of time.time()

property exists_local: bool

Returns True if the file exists locally

last_seen(where: str) int[source]

Returns the last_seen_<where>

Where <where> is remote or local

Parameters:

where – remote or local

property last_seen_local: int

Returns the time this file was last confirmed seen on the local machine

property last_seen_remote: int

Returns the time this file was last confirmed seen on the remote machine

property local_mtime: int

Returns the mtime of the local file

property size: int

Returns the filesize (needs to be set externally)

-1 if not set

sub(source, target, mode: str = 'python') bool[source]

Substitute source for target

Parameters:
  • source – file content to sub

  • target – intended replacement

  • mode – function to use, default to Python replace

Returns:

True if a substitution was executed, False otherwise

chmod(mod: int)[source]

chmod the local file, if it exists

python3 chmod requires an octal input, so convert the base10 input